package com.fh.controller.system.timer;

import com.fh.controller.system.tools.SmsUtil;
import com.fh.service.building.bill.BillService;
import com.fh.util.DateUtil;
import com.fh.util.PageData;
import org.quartz.DisallowConcurrentExecution;
import org.quartz.Job;
import org.quartz.JobExecutionContext;

import java.util.List;

/**
 * Created by caozengling on 2018年6月15日.
 * 这个定时器 主要向 客户 发送消息
 */
@DisallowConcurrentExecution
public class Customer implements Job {

    private BillService billService = (BillService)ApplicationContextUtil.getBean("billService");

    @Override
    public void execute(JobExecutionContext context) {
        this.pay_reminder_day();//付款提醒日
    }

    private void pay_reminder_day() {
        try {
            PageData pd = new PageData();
            pd.put("PAY_DATE", DateUtil.getAfterDayDate("-3"));
            List<PageData> list = billService.pay_reminder_day(pd);//获取所有客户的付款的提醒
            if (list.size() > 0) {
                for (int i = 0; i < list.size(); i++) {
                    // TODO 发送短信提醒
                    String tel=list.get(i).getString("TX_TEL");
                    String price=list.get(i).getString("TOTAL_PRICE");
                    System.out.println("+++++++++++++++++++++++++");
//                    SmsUtil.sendSms(tel,price);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}